1. Field of the Invention
The present invention describes a method and processor for editing electronic document, and more particularly a method and editing processor for adding graphics object with simple manner.
2. Discussion of the Background
Recently, a pdf (portable document format) format is widely used as a common document-exchanging format because it can read and print documents on different platforms and among different versions of an application software. A document created with the pdf format includes a character part and a graphics part that indicates figure, etc. The character part makes it possible to search for a character and to reuse the searched character in other application software.
More specifically, a pdf file 100 includes four parts, i.e., a file header 110, a file body 120, a cross-reference table 130, and a file trailer 140 referring to FIG. 1. The file header 110 is provided in a leading portion of the pdf file 100 and defines information of data itself as header information. The file header 110 includes, for example, date on document creation, creator's name, etc. at a predetermined area reserved at each page. The file body 120 defines Contents of the pdf document. Data included in the file body 120 is defined to have objects in array form.
The cross-reference table 130 describes a position of each object in list form in order to make random access possible. The file trailer 140 is a footer that represents the end of the file. The file header 110, the file body 120, the cross-reference table 130, and the file trailer 140 comprise a data set. The data set is repeated.
Referring to a description image of FIG. 2, the file body 120 of the pdf file 100 is now described in detail. As described above, the file body 120 is defined by an array of the objects (Xobj-endobj). X is an identifier ID to identify the object and is a numeral, character, symbol, or a combination of these. In the embodiment of FIG. 2, numerals 30, 40, and 50 are used as identifiers. Each object 200, 210, and 220 can refer to other objects using this identifier ID.
In the embodiment of FIG. 2, the object 200 having the identifier ID 30 includes items with format of [40R] and [50R] as Contents items (Contents). [40R] and [50R] refer object identifiers 40 and 50, respectively.
Referring to FIG. 3, process steps to define the file body 120 with draw graphics command and to draw the graphics are described. FIGS. 3A, 3B, and 3C illustrate description image, merged object image, and drawing image, respectively.
One of the objects in the file body 120 manages information on a page of the pdf file 100. In this embodiment, the object [30obj] manages the information on a page of the pdf file 100. Further, a draw Contents item in the object [30obj] manages drawing information of the page. The draw Contents item designates [40obj] or [50obj] that is called Content-stream. Each Content-stream includes command lines, such as a draw graphics object command to draw graphics object and a change graphics state command to change state of the graphics object. These commands may be compressed.
To draw the image shown in FIG. 3C, the Content-streams described in the Contents item of [30obj] in FIG. 3A are merged sequentially. The Content-stream as shown in FIG. 3B is generated. Using a browsing software such as Viewer, commands are read and interpreted from a top of the merged Content-stream. Drawing procedure is then fixed and the image is drawn.
There are two main commands with respect to the commands of the Content-stream, i.e., a draw graphics object command and a change graphics state command. The draw graphics object commands are a command to draw graphics object 1 at a backside of an existing object using graphics operator, a command to draw graphics object 2 at a backside of the existing object using graphics operator, and a command to draw graphics object 3 at a backside of the existing object using graphics operator as shown in FIGS. 3A and 3B. As these commands are interpreted sequentially, the graphics objects are drawn sequentially in the same order. When the graphics object is drawn, it is performed in order to draw the object in accordance with a definition that determines whether to draw the graphics object at a front side of the existing object, or at a back side of the existing object.
The change graphics state command is a command to perform information change of color, axis and so on. This command is maintained until the Contents is revised, or the command being implemented leaves an effective region (scope) of the change graphics state command.
When the scope of the change graphic state is not included in the merged Content-Stream, the draw graphic object command may not be affected by a change graphic state command 3 that is implemented at an immediately preceding step, but may be affected by an instruction to change graphics state commands 1 and 2. For example, when there is no instruction to change an axis system by the change graphic state command 1, graphics is drawn with an axis defined by the change graphics state command 1 at the implementation of the draw graphics object command.
The scope is now described in detail. When the graphics state is changed, the state condition is maintained from a time the state condition is changed to an end time of the Content-stream. For example, the scope of the change graphics state command 1 that changes graphics object during the Content-stream in FIG. 4 is maintained from a time the Content-stream is changed to an end time of the Content-stream. Similarly, the scope of the change graphics state command 2 that changes graphics object is maintained from a time the Content-stream is changed to an end time of the Content-stream. For this reason, both drawing commands 2 and 3 are implemented under the effect of the graphics state defined by the change graphics state command 1.
In the pdf format, two types of operators that are q-operator and Q-operator are provided to localize the scope that is the effective region for changing graphics state. As for the graphics state around the region framed by the q-operator and the Q-operator corresponding to the q-operator, the graphics state is invalid in a region after the Q-operator and is returned to the graphics state before the q-operator. These q-operator and Q-operator can be consolidated in a nested block (a plurality of commands can be wrapped up as a unit.) A number of the nested blocks, i.e., a single consolidated unit, is limited up to 28 in the pdf format.
Referring to FIG. 5, a scope of the change graphics state command 2 framed by the q-operator and the Q-operator is a range between the end of the change graphics state command 2 and the Q-operator. Therefore, the above scope does not affect the draw graphics object command 3. Thus, using the q-operator and the Q-operator, the graphics can be changed tentatively without disturbing the graphics state. However, a lot of calculations are needed to implement this change.
FIG. 6 illustrates example images of file body, i.e., a description image, an object image and a drawing image when graphics are added to a pdf file. The example images illustrate a case when [60obj] is added. Two implementation steps are needed to add the graphics object, i.e., a generation step that generates a command to draw the graphics object to be added, and an adding step that adds the generated command as a Contents item to [30obj] that holds the page information.
During the implementation of the above processes, the following should be considered. The draw graphics object command may be affected by the change graphics state commands 1, 2 and 3 that are existed before the implementation. Therefore, it is necessary to remove the effect of the existing graphics state in some way in order to draw the added graphics object as the user intended.
Currently, the following process steps are generally performed. As a first process step, a draw graphics object command is analyzed and a current available graphic state is calculated. As a second process step, a change graphic state command that removes the effect of the current graphic state is inserted, before the implementation of the drawing graphics object command to be added based on the calculation result.
A method to treat a Pdf file, in which an existing graphic state is changed by changing an axis in the following two steps, is described in more detail. At the first step, an axis system is moved by 10 units in a x-axis direction and is shifted by 20 units parallel to a y-axis. At the second step, the axis system is rotated 30 degrees.
First, by analyzing the Contents-stream, the graphics state is confirmed, that is, whether the graphics is in a state in which the axis system is moved by 10 units in a x-axis direction, is shifted by 20 units parallel to a y-axis, and is rotated 30 degrees. Next, based on the result of the analysis, a command that returns the axis system to a default state is added to remove the effect of the existing graphics state. The added command causes the axis system to move by −10 units in a x-axis direction, the axis system to shift by −20 units parallel to a y-axis, and the axis system to rotate 30 degrees. As a result, the effect of the existing graphics state can be removed.
In another technology to solve the problem, when the header and footer are provided, portions in which header and footer are provided are checked in advance. A white image is provided only when an image is present at a position at which the footer is provided. Thus, the adding process is performed automatically to a non-intended image region.
In this technology, the region to which the header and footer is provided is examined to determine whether or not an image is present. After the entire information of the page of the pdf file is extracted, a specific region is checked. If an image is present in the specific region, a white image is provided. If an image is not present in the specific region, the header and footer are provided. Thus, the objects i.e., header and footer can be added to an intended page of the pdf file. However, the implementation requires a lot of calculation time.